home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Human Interface Toolbox / ProgressBars / AppleEvents.c next >
Encoding:
Text File  |  2000-09-28  |  2.8 KB  |  123 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        AppleEvents.c
  3.  
  4.     Contains:    Handlers for the 4 "required" events
  5.  
  6.     Written by: Chris White    
  7.  
  8.     Copyright:    Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 8/10/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24.  
  25.  
  26.  
  27. // System Includes
  28.  
  29. #ifndef __APPLEEVENTS__
  30.     #include <AppleEvents.h>
  31. #endif
  32.  
  33.  
  34.  
  35.  
  36. // Application includes
  37.  
  38. #ifndef __BAREBONES__
  39.     #include "BareBones.h"
  40. #endif
  41.  
  42. #ifndef __PROTOTYPES__
  43.     #include "Prototypes.h"
  44. #endif
  45.  
  46.  
  47.  
  48.  
  49.  
  50. // Static Prototypes
  51. static pascal OSErr HandleOapp ( AEDescList* aevt, AEDescList* reply, long refCon );
  52. static pascal OSErr HandleQuit ( AEDescList* aevt, AEDescList* reply, long refCon );
  53. static pascal OSErr HandleOdoc ( AEDescList* aevt, AEDescList* reply, long refCon );
  54. static pascal OSErr HandlePdoc ( AEDescList* aevt, AEDescList* reply, long refCon );
  55.  
  56.  
  57.  
  58. #pragma segment Initialize
  59.  
  60. OSErr InstallAppleEventHandlers ( void )
  61. {
  62.     OSErr    theErr;
  63.     
  64.     
  65.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEOpenApplication, NewAEEventHandlerProc ( HandleOapp ), 0, false );
  66.     if ( theErr )    goto CleanupAndBail;
  67.  
  68.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEOpenDocuments, NewAEEventHandlerProc ( HandleOdoc ), 0, false );
  69.     if ( theErr )    goto CleanupAndBail;
  70.  
  71.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEPrintDocuments, NewAEEventHandlerProc ( HandlePdoc ), 0, false );
  72.     if ( theErr )    goto CleanupAndBail;
  73.  
  74.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEQuitApplication, NewAEEventHandlerProc ( HandleQuit ), 0, false );
  75.     if ( theErr )    goto CleanupAndBail;
  76.     
  77.     
  78. CleanupAndBail:
  79.  
  80.     return theErr;
  81.     
  82. }    // InstallAppleEventHandlers
  83.  
  84.  
  85.  
  86. #pragma segment Core
  87.  
  88. static pascal OSErr HandleOapp ( AEDescList* aevt, AEDescList* reply, long refCon )
  89. {
  90.     #pragma unused(aevt,reply,refCon)
  91.     return errAEEventNotHandled;
  92. }
  93.  
  94.  
  95.  
  96. static pascal OSErr HandleOdoc ( AEDescList* aevt, AEDescList* reply, long refCon )
  97. {
  98.     #pragma unused(aevt,reply,refCon)
  99.     return errAEEventNotHandled;
  100. }
  101.  
  102.  
  103.  
  104. static pascal OSErr HandlePdoc ( AEDescList* aevt, AEDescList* reply, long refCon )
  105. {
  106.     #pragma unused(aevt,reply,refCon)
  107.     return errAEEventNotHandled;
  108. }
  109.  
  110.  
  111.  
  112. static pascal OSErr HandleQuit ( AEDescList* aevt, AEDescList* reply, long refCon )
  113. {
  114.     #pragma unused(aevt,reply,refCon)
  115.     gQuit = true;
  116.     
  117.     return noErr;
  118. }
  119.  
  120.  
  121.  
  122.  
  123.